/*
 * Copyright (c) 2018-2999 九五云信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.service;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.yami.shop.bean.app.dto.MyOrderDto;
import com.yami.shop.bean.app.dto.OrderCountData;
import com.yami.shop.bean.app.dto.ShopCartOrderMergerDto;
import com.yami.shop.bean.app.dto.StationSalesDto;
import com.yami.shop.bean.model.Order;
import com.yami.shop.bean.model.OrderItem;
import com.yami.shop.bean.param.OrderParam;
import com.yami.shop.bean.param.OrderPayParam;
import com.yami.shop.common.util.PageParam;
import org.apache.ibatis.annotations.Param;
import com.yami.shop.bean.param.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author lgh on 2018/09/15.
 */
public interface OrderService extends IService<Order> {


    Order getOrderByOrderNumber(String orderNumber);

    /**
     * 根据订单号和用户id获取订单
     * @param orderNumber
     * @param userId
     * @return
     */
    Order getOrderByOrderNumberAndUserId(String orderNumber,String userId, boolean valid);

    /**
     * 根据店铺id和订单号获取订单
     * @param orderNumber
     * @param shopId
     * @return
     */
    Order getOrderByOrderNumberAndShopId(String orderNumber,Long shopId, boolean valid);


    ShopCartOrderMergerDto putConfirmOrderCache(String userId, ShopCartOrderMergerDto shopCartOrderMergerDto);

    ShopCartOrderMergerDto getConfirmOrderCache(String userId);

    void removeConfirmOrderCache(String userId);


    List<Order> submit(String userId, ShopCartOrderMergerDto mergerOrder);

    void delivery(Order order);

    List<Order> listUnRefundOrderAndOrderItems(Integer orderStatus, DateTime lessThanUpdateTime);

    void cancelOrders(List<Order> orders);

    void receiptOrder(List<Order> orders);

//    List<Order> listOrdersDetialByOrder(Order order, Date startTime, Date endTime);

    IPage<Order> pageOrdersDetialByOrderParam(Page<Order> page, OrderParam orderParam);

    void deleteOrders(List<Order> orders);

    OrderCountData getOrderCount(String userId);

    double sumTotalDistributionAmountByOrderItem(List<OrderItem> orderItems);

    void changeAmount(Order order);

    void soldExcel(OrderParam orderParam, HttpServletResponse response);

    List<Order> getOrderPayInfoByOrderNumber(List<String> orderNumberList);

    Order getOrderDetailByOrderNumberAndShopId(String orderNumber, Long shopId, Integer lang);

    /**
     * 获取退款的订单项的id和退款状态
     * @param orderId
     * @return
     */
    Map<Long, Integer> getOrderItemMap(Long orderId);

    Order getOrderAndOrderItemByOrderNumber(String orderNumber);

    void getOrderItenRefundStatus(Order order);

    IPage<MyOrderDto> orderListByStatus(PageParam<MyOrderDto> page, Integer status, Long stationId);

    Boolean orderStationByOrderNumber(List<String> orderNumberList, String userId, Long stationId);

    CustomerRespParam countPayNum(CustomerReqParam param);

    List<CustomerPayParam> countCustomerParam(CustomerReqParam param);

    Integer countMemberPayNum(CustomerReqParam param);

    CustomerDealRespParam getCustomerDeal(CustomerReqParam param);

    List<CustomerRFMRespParam> countPayNumRFM(CustomerRFMReqParam param);

    CustomerConsumeRespParam getConsumePower(CustomerConsumeReqParam param);

    CustomerConsumeRespParam getConsumeFrequency(CustomerConsumeReqParam param);

    CustomerRepurchaseRespParam getConsumeRepurchaseCount(CustomerConsumeReqParam param);

    MemberContributeRespParam getMemberContributeValue(MemberReqParam param);

    MemberDealRespParam getMemberDeal(MemberReqParam param);

    List<Order> getOrderAndOrderItemByOrderNumberList(Set<String> orderNumberList);

    List<CustomerRFMRespTableParam> countPayNumRFM2(CustomerRFMReqParam param);

    UserManagerParam getConsumeData(UserManagerParam param);

    IPage<Order> pageByUserId(PageParam<Order> page, String userId);
}
